package cn.com.w.jdk.thread.pool.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 线程池的配置文件
 */
@Component
@ConfigurationProperties(prefix = "thread-pool")
@PropertySource(value = {"classpath:/config/threadPoolConfig.yml"},
        ignoreResourceNotFound=false,
        encoding="UTF-8",
        name="threadPoolConfig.yml")
public class ThreadPoolConfigYml {

    private int corePoolSize;
    private int maxPoolSize;
    private int queueCapacity;
    private int keepAliveSeconds;

    public int getCorePoolSize() {
        if (this.corePoolSize == 0) {
            return 1;
        }
        return corePoolSize;
    }

    public void setCorePoolSize(int corePoolSize) {
        this.corePoolSize = corePoolSize;
    }

    public int getMaxPoolSize()
    {
        if (this.maxPoolSize == 0) {
            return 2;
        }
        return maxPoolSize;
    }

    public void setMaxPoolSize(int maxPoolSize) {
        this.maxPoolSize = maxPoolSize;
    }

    public int getQueueCapacity() {
        if (this.queueCapacity == 0) {
            return 3;
        }
        return queueCapacity;
    }

    public void setQueueCapacity(int queueCapacity) {
        this.queueCapacity = queueCapacity;
    }

    public int getKeepAliveSeconds()
    {
        if (this.keepAliveSeconds == 0) {
            return 4;
        }
        return keepAliveSeconds;
    }

    public void setKeepAliveSeconds(int keepAliveSeconds) {
        this.keepAliveSeconds = keepAliveSeconds;
    }


}